import { defineStore } from 'pinia'
import { ref } from 'vue'
import { permissionApi } from '@/api'

export const usePermissionStore = defineStore('permission', () => {
  const groupedPermissionList = ref<any[]>([])

  const fetchGroupedPermissionList = async () => {
    try {
      const { data } = await permissionApi.getGroupedPermissionList()
      groupedPermissionList.value = data
    } catch (error) {
      console.error('獲取權限列表失敗:', error)
    }
  }

  return {
    groupedPermissionList,
    fetchGroupedPermissionList,
  }
})
